package algorithm.poj.p3000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;


/**
 * 分析：
 * 简单分析可以知道，答案是最大和最小数差值的2倍
 * 实现：
 * 经验：
 * 教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P3632 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P3632.class.getResource("P3632.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		StringBuffer sb = new StringBuffer("");
		String line = stdin.readLine();
		int t = Integer.valueOf(line.trim());
		for (int i = 0; i < t; i ++) {
			line = stdin.readLine();
			int n = Integer.valueOf(line.trim());
			StringTokenizer st = new StringTokenizer(stdin.readLine());
			int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
			for (int j = 0; j < n; j ++) {
				int d = Integer.valueOf(st.nextToken());
				if (j == 0) {
					min = max =d;
				} else {
					if (d < min) {
						min = d;
					} else if (d > max) {
						max = d;
					}
				}
			}
			sb.append((max-min)*2).append("\n");
		}
		System.out.println(sb);
	}
}